package com.zoweunion.mechanic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zoweunion.mechanic.util.Orgin;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.zoweunion.mechanic.dao.TSSsOrderCheckDeployServerDao;
import com.zoweunion.mechanic.entity.TSSsOrderCheckDeployServerEntity;
import com.zoweunion.mechanic.service.TSSsOrderCheckDeployServerService;


@Service("tSSsOrderCheckDeployServerService")
public class TSSsOrderCheckDeployServerServiceImpl extends ServiceImpl<TSSsOrderCheckDeployServerDao, TSSsOrderCheckDeployServerEntity> implements TSSsOrderCheckDeployServerService {

    @Autowired
    private TSSsOrderCheckDeployServerDao tSSsOrderCheckDeployServerDao;


    @Override
    public PageInfo queryPage(Map<String, Object> map)  {
        Integer pageSize = Integer.valueOf(map.get("pageSize").toString());
        Integer currentPage = Integer.valueOf(map.get("currentPage").toString());
        PageHelper.startPage(currentPage, pageSize);
        List<TSSsOrderCheckDeployServerEntity> mapList = tSSsOrderCheckDeployServerDao.queryPage(map);
        PageInfo<TSSsOrderCheckDeployServerEntity> mapPageInfo = new PageInfo<>(mapList);
        return mapPageInfo;
    }

    @Override
    public List<TSSsOrderCheckDeployServerEntity> tSSsOrderCheckDeployInfo(Map<String, Object> params) {
        String sId = Orgin.getString(params, "s_id");
        List<TSSsOrderCheckDeployServerEntity> arrayList = new ArrayList<>();
        arrayList =tSSsOrderCheckDeployServerDao.selectDeployBySid(sId);
        if (arrayList.size()==0){
            arrayList = tSSsOrderCheckDeployServerDao.selectDeploy();
        }
        return arrayList;
    }

}